package kaizen;

// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 07/02/2013 05:29:06 p.m.
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   pago.java

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import kaizen.jdbc.DbAppUnivC;
import kaizen.jdbc.dbRecord;
import kaizen.nomweb.templates;
import kaizen.nomweb.utilerias;

public class pago extends HttpServlet
{

    public pago()
    {
        datColorRen = "";
        datFont = "";
        datTamFont = "";
        datColorFont = "";
        dirPlantillasGenerales = "";
        plant_conf = "pgral_ideograma/pago.html";
        error = "";
    }

    public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws ServletException, IOException
    {
        httpservletresponse.setContentType("text/html");
        PrintWriter printwriter = httpservletresponse.getWriter();
        javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(false);
        String s = generaPantalla(httpservletrequest, httpservletresponse, error);
        printwriter.println(s);
    }

    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws IOException, ServletException
    {
        doGet(httpservletrequest, httpservletresponse);
    }

    public void generaAmbiente(HttpServletRequest httpservletrequest)
        throws IOException
    {
        String s = utilerias.tomaParametro("dic_sistema", httpservletrequest);
        if(s == null)
            s = "mocte";
        String s1 = "/kaizen/" + s + "Web.properties";
        Properties properties = utilerias.loadProperties(s1);
        dirPlantillasGenerales = properties.getProperty("plantillas");
        datColorRen = properties.getProperty("datColorRen");
        datFont = properties.getProperty("datFont");
        datTamFont = properties.getProperty("datTamFont");
        datColorFont = properties.getProperty("datColorFont");
    }

    public String generaPantalla(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, String s)
        throws IOException
    {
        String s1 = httpservletrequest.getParameter("serie");
        String s2 = httpservletrequest.getParameter("numero");
        PrintWriter printwriter = httpservletresponse.getWriter();
        generaAmbiente(httpservletrequest);
        String s3 = "";
        String s4 = "";
        String s6 = "";
        String s8 = "";
        String s9 = "";
        String s11 = "";
        String s13 = "";
        String s15 = "";
        String s16 = "";
        double d = 0.0D;
        double d1 = 0.0D;
        String s17 = " SELECT 1,  'FACT',  apin_fact_serie||'-'||apin_fact_numero,   fact_clnt_numero||'-'||fact_razon_social,  fact_toneladas,   FACT_SUBTOTAL_FACTURA + FACT_MONTO_IVA,  apin_importe_total,  pain_importe_total,   TO_CHAR(pain_fecha_pago, 'dd/mm/yyyy,  hh:mi am')  FROM   scc_aplicaciones_internet, scc_facturas, scc_pagos_internet  WHERE  apin_fact_serie  = fact_serie  AND    apin_fact_numero = fact_numero  AND    apin_pain_numero = pain_numero  AND    apin_pain_serie  = '" + s1 + "' " + " AND    apin_pain_numero = " + s2 + " UNION " + " SELECT DECODE(NOCA_TIPO_NOTA,'A',3,2),DECODE(NOCA_TIPO_NOTA,'A','AVCA','NOCA'), " + " apin_noca_serie||'-'||apin_noca_numero, noca_clnt_numero||'-'||noca_razon_social, " + " noca_toneladas, noca_SUBTOTAL_nota + noca_MONTO_IVA, apin_importe_total, pain_importe_total, " + " TO_CHAR(pain_fecha_pago, 'dd-mm-yyyy') " + " FROM   scc_aplicaciones_internet, scc_notas_cargo, scc_pagos_internet " + " WHERE  apin_noca_serie  = noca_serie " + " AND    apin_noca_numero = noca_numero " + " AND    apin_pain_numero = pain_numero " + " AND    apin_pain_serie  = '" + s1 + "' " + " AND    apin_pain_numero = " + s2 + " UNION " + " SELECT 4,'PAGA',apin_paga_serie||'-'||apin_paga_numero, " + " paga_clnt_numero||'-'||paga_razon_social, paga_toneladas, " + " paga_SUBTOTAL_pagare + paga_MONTO_IVA, apin_importe_total, pain_importe_total, " + " TO_CHAR(pain_fecha_pago, 'dd-mm-yyyy') " + " FROM   scc_aplicaciones_internet, scc_pagares, scc_pagos_internet " + " WHERE  apin_paga_serie  = paga_serie " + " AND    apin_paga_numero = paga_numero " + " AND    apin_pain_numero = pain_numero " + " AND    apin_pain_serie  = '" + s1 + "' " + " AND    apin_pain_numero = " + s2 + " ORDER BY 1";
        Vector vector = DbAppUnivC.execQuery(s17);
        String s18 = "";
        for(int i = 0; i < vector.size(); i++)
        {
            dbRecord dbrecord = (dbRecord)vector.elementAt(i);
            String s5 = dbrecord.getField(2);
            String s7 = dbrecord.getField(3);
            s8 = dbrecord.getField(4);
            String s10 = dbrecord.getField(5);
            String s12 = utilerias.redondea(dbrecord.getField(6));
            String s14 = utilerias.redondea(dbrecord.getField(7));
            s15 = utilerias.redondea(dbrecord.getField(8));
            s16 = dbrecord.getField(9);
            d1 = Double.valueOf(dbrecord.getField(8)).doubleValue();
            d += Double.valueOf(dbrecord.getField(7)).doubleValue();
            if(i % 2 == 1)
                s18 = datColorRen;
            else
                s18 = "#FFFFFF";
            s3 = s3 + "<tr>";
            s3 = s3 + templates.tablaCol(s5, datColorFont, datFont, datTamFont, s18);
            s3 = s3 + templates.tablaCol(s7, datColorFont, datFont, datTamFont, s18);
            s3 = s3 + utilerias.replaceString1(utilerias.replaceString1(templates.tablaCol(s10, datColorFont, datFont, datTamFont, s18), "<td bgcolor=\"" + s18 + "\">", "<td bgcolor=\"" + s18 + "\" <div align=\"right\">"), "</td>", "</div></td>");
            s3 = s3 + utilerias.replaceString1(utilerias.replaceString1(templates.tablaCol(s12, datColorFont, datFont, datTamFont, s18), "<td bgcolor=\"" + s18 + "\">", "<td bgcolor=\"" + s18 + "\" <div align=\"right\">"), "</td>", "</div></td>");
            s3 = s3 + utilerias.replaceString1(utilerias.replaceString1(templates.tablaCol(s14, datColorFont, datFont, datTamFont, s18), "<td bgcolor=\"" + s18 + "\">", "<td bgcolor=\"" + s18 + "\" <div align=\"right\">"), "</td>", "</div></td>");
            s3 = s3 + "</tr>";
        }

        if(d != d1)
        {
            if(s18.equals("#FFFFFF"))
                s18 = datColorRen;
            else
                s18 = "#FFFFFF";
            double d2 = d1 - d;
            s3 = s3 + "<tr>";
            s3 = s3 + templates.tablaCol("ANTI", datColorFont, datFont, datTamFont, s18);
            s3 = s3 + templates.tablaCol("", datColorFont, datFont, datTamFont, s18);
            s3 = s3 + templates.tablaCol("", datColorFont, datFont, datTamFont, s18);
            s3 = s3 + templates.tablaCol("", datColorFont, datFont, datTamFont, s18);
            s3 = s3 + utilerias.replaceString1(utilerias.replaceString1(templates.tablaCol(utilerias.redondea(Double.toString(d2)), datColorFont, datFont, datTamFont, datColorRen), "<td bgcolor=\"" + s18 + "\">", "<td bgcolor=\"" + s18 + "\" <div align=\"right\">"), "</td>", "</div></td>");
            s3 = s3 + "</tr>";
        }
        String s19 = templates.getHost();
        String s20 = dirPlantillasGenerales + plant_conf;
        String s21 = "";
        s21 = templates.generaPlantilla(s20, s19);
        s21 = utilerias.replaceString1(s21, "--cliente--", s8);
        s21 = utilerias.replaceString1(s21, "--serie--", s1);
        s21 = utilerias.replaceString1(s21, "--numero--", s2);
        s21 = utilerias.replaceString1(s21, "--pago--", s15);
        s21 = utilerias.replaceString1(s21, "--fecha--", s16);
        s21 = utilerias.replaceString1(s21, "--tabla--", s3);
        s21 = utilerias.replaceString1(s21, "--enviototal--", s15);
        return s21;
    }

    String datColorRen;
    String datFont;
    String datTamFont;
    String datColorFont;
    String dirPlantillasGenerales;
    String plant_conf;
    String error;
}